package cn.zh.planmanager.domain.plan.model.entity;

import cn.zh.planmanager.domain.plan.convert.PlanSetConvert;
import cn.zh.planmanager.domain.plan.model.value.ProjectInfo;
import cn.zh.planmanager.domain.plan.repository.PlanSetRepository;
import cn.zh.planmanager.infrastructure.common.Entity;
import cn.zh.planmanager.infrastructure.entity.PlanSetEntity;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * @author zh
 */
@Data
public class Plan implements Entity<Long> {

    private Long id;

    /**
     * 工作内容
     */
    private String workContent;

    private Integer planSetId;

    /**
     * 所属工程
     */
    private ProjectInfo projectInfo;

    /**
     * 开始时间
     */
    private LocalDateTime startTime;

    /**
     * 结束时间
     */
    private LocalDateTime endTime;


    /**
     * 查询计划集信息
     */
    public PlanSet getPlanSetInfo(PlanSetRepository planSetRepository){
        PlanSetEntity entity = planSetRepository.findById(planSetId);
        return PlanSetConvert.convertToDo(entity);
    }

    @Override
    public boolean sameAsId(Long id) {
        return id.equals(this.id);
    }
}
